import request from '@/utils/request'

// 导出所有API接口
export default {
  // 用户相关接口
  user: {
    // 登录
    login: (data: { username: string; password: string }) => 
      request.post('/auth/login', data),
    
    // 登出
    logout: () => 
      request.post('/auth/logout'),
    
    // 获取用户信息
    getInfo: () => 
      request.get('/auth/info'),
    
    // 修改密码
    changePassword: (data: { oldPassword: string; newPassword: string }) => 
      request.post('/auth/change-password', data)
  },
  
  // 聊天相关接口
  chat: {
    // 发送消息
    sendMessage: (data: { message: string; type?: string }) => 
      request.post('/chat/send', data),
    
    // 获取聊天历史
    getHistory: (params: { page?: number; pageSize?: number }) => 
      request.get('/chat/history', { params }),
    
    // 删除聊天记录
    deleteHistory: (id: string) => 
      request.delete(`/chat/history/${id}`),
    
    // 清空聊天记录
    clearHistory: () => 
      request.delete('/chat/history')
  },
  
  // 文件相关接口
  file: {
    // 读取文件
    readFile: (path: string) => 
      request.get('/file/read', { params: { path } }),
    
    // 创建文件
    createFile: (data: { path: string; content: string }) => 
      request.post('/file/create', data),
    
    // 修改文件
    updateFile: (data: { path: string; content: string }) => 
      request.put('/file/update', data),
    
    // 删除文件
    deleteFile: (path: string) => 
      request.delete('/file/delete', { params: { path } }),
    
    // 创建文件夹
    createFolder: (path: string) => 
      request.post('/folder/create', { path }),
    
    // 删除文件夹
    deleteFolder: (path: string) => 
      request.delete('/folder/delete', { params: { path } }),
    
    // 获取文件列表
    getFileList: (path: string) => 
      request.get('/file/list', { params: { path } })
  },
  
  // 网页相关接口
  web: {
    // 获取网页内容
    fetchWebContent: (url: string) => 
      request.get('/web/fetch', { params: { url } })
  },
  
  // 时间相关接口
  time: {
    // 获取当前时间
    getCurrentTime: () => 
      request.get('/time/current'),
    
    // 设置闹钟
    setAlarm: (data: { time: string; message: string }) => 
      request.post('/time/alarm', data),
    
    // 获取闹钟列表
    getAlarms: () => 
      request.get('/time/alarm/list'),
    
    // 删除闹钟
    deleteAlarm: (id: string) => 
      request.delete(`/time/alarm/${id}`)
  },
  
  // 工具相关接口
  tools: {
    // 文本处理
    textProcess: (data: { text: string; operation: string }) => 
      request.post('/tools/text-process', data),
    
    // 数据分析
    dataAnalysis: (data: { data: any; type: string }) => 
      request.post('/tools/data-analysis', data),
    
    // 图像生成
    generateImage: (data: { prompt: string; style?: string }) => 
      request.post('/tools/generate-image', data),
    
    // 获取工具列表
    getToolsList: () => 
      request.get('/tools/list')
  }
}